﻿using Moq;
using NUnit.Framework;
using Shinkansen.Crunchers;
using Shinkansen.Support;

namespace Shinkansen.Test
{
    [TestFixture]
    public class CruncherBuilderTest
    {
        private CruncherBuilder _builder = CruncherBuilder.Current;

        [TearDown]
        public void TearDown ()
        {
            _builder.Reset ();
        }

        [Test]
        public void Intializes_default_crunchers ()
        {
            Assert.IsInstanceOf (typeof(MicrosoftCssCruncher), _builder.GetCssCruncher ());
            Assert.IsInstanceOf (typeof(MicrosoftJsCruncher), _builder.GetJsCruncher ());
        }

        [Test]
        public void Can_set_alternate_css_cruncher ()
        {
            Mock<ICssCruncher> newCssCruncher = new Mock<ICssCruncher>();
            _builder.SetCssCruncher (newCssCruncher.Object);

            Assert.AreSame (newCssCruncher.Object, _builder.GetCssCruncher ());
        }

        [Test]
        public void Can_set_alternate_js_cruncher ()
        { 
            Mock<IJsCruncher> newJsCruncher = new Mock<IJsCruncher> ();
            _builder.SetJsCruncher (newJsCruncher.Object);

            Assert.AreSame (newJsCruncher.Object, _builder.GetJsCruncher ());
        }
    }
}
